package com.tuanbiao.ui.upload;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.daimajia.swipe.SwipeLayout;
import com.hzjq.data.entity.BlastEntity;
import com.tuanbiao.R;

/**
 * @author abiao
 * @since 2022/4/12 15:54
 */
public class UploadDataAdapter extends BaseQuickAdapter<BlastEntity, BaseViewHolder> {
    public UploadDataAdapter() {
        super(R.layout.item_upload_data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, BlastEntity entity) {
        boolean uploaded = entity.getUploadStatus() == 1;
        holder.setText(R.id.tv_contract_code, getContext().getString(R.string.upload_data_adapter_contract_code, entity.getHtId()))
                .setText(R.id.tv_count, getContext().getString(R.string.upload_data_adapter_count, entity.getBlastCount()))
                .setText(R.id.tv_time, getContext().getString(R.string.upload_data_adapter_blast_time, entity.getBlastTime()))
                .setText(R.id.btn_upload, !uploaded ? "上传数据" : "已上传");
        holder.setEnabled(R.id.btn_upload, !uploaded);
        SwipeLayout swipeLayout = holder.getView(R.id.sl_content);
        swipeLayout.setSwipeEnabled(uploaded);
    }
}
